package com.fdd;
import com.fdd.dao.BookDao;
import com.fdd.service.BookService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import javax.sql.DataSource;

// 测试自动装配，在配置文件中设置bookService这个bean，并且为之创建setter方法。
public class App {
    public static void main(String[] args) {
        System.out.println("Hello World!");
        //获取IOC容器 ApplicationContext
        ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
        ctx.registerShutdownHook();

        //BookService bookService = (BookService)ctx.getBean("bookService");
        //bookService.save();

        //DataSource dataSource = (DataSource) ctx.getBean("dataSource");
        //System.out.println(dataSource);

        DataSource dataSource1 = (DataSource) ctx.getBean("c3p0");
        System.out.println(dataSource1);
    }
}
